Skip to content

Add an Edit link and a placeholder edit page - #107

Open
mihailefter wants to merge 1 commit into
masterfrom
feature/edit-access
Open

mihailefter wants to merge 1 commit into
masterfrom
feature/edit-access

Conversation

@mihailefter

Copy link
Copy Markdown
Collaborator

Add an Edit link next to the resource title, shown to users with W permission on that resource and to admins, when the API docs advertise its PUT operation. It opens a placeholder edit page with breadcrumbs, the title and Cancel. The page says “Editing is not implemented yet”; the form follows in subsequent PRs.

Opening an edit URL without write access redirects to the resource, as in the old client. Logged-out users are redirected to login. If the access check fails, the page displays the error rather than treating it as a permission denial.

The same access rules apply to the root: admins and members with W can open its edit page when its PUT operation is advertised.

Assisted-by: LLM claude

@dennisvang dennisvang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mihailefter, this looks good! 🙂

Only a few minor questions/suggestions in the comments.

const { isLoggedIn } = useAuth()
const { isLoggedIn, isAdmin } = useAuth()
const membershipName = ref<string | null>(null)
const hasWrite = ref(false)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const hasWrite = ref(false)
const hasWritePermission = ref(false)

and so on

Comment thread src/composables/useMeta.ts Resolved
/>
</div>
<div v-if="deleteAvailable" class="resource-actions">
<div v-if="canEdit || deleteAvailable" class="resource-actions">

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use consistent names here, as in canEdit and canDelete, or is there a specific reason for using deleteAvailable?

'fetch',
mockApiFetch(okJson(), {
openapi: '3.0.1',
paths: { '/': { put: { operationId: 'putResearch Hub' } } },

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'putResearch Hub' makes me wonder what that is about and if it has any meaning in the application code. Could we use a more generic mock operationId value like 'mockOperation' or something like that?

Or perhaps use a variable, also because it is used twice:

const mockOperationId = 'some operation id'


it('allows members with W when the PUT is advertised', async () => {
offered.add('putcatalog')
const { canEdit, loaded } = await editAccess(metaWith('Owner', ['C', 'W', 'D', 'A']))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps we could introduce Enums for the membership name and permission codes (not just here, but in the app code)?

For example:

enum MembershipName {
  Owner = 'Owner',
  DataProvider = 'Data Provider',
}

enum PermissionCode {
  Administration = 'A',
  Create = 'C',
  Delete = 'D',
  Insert = 'I',
  Read = 'R',
  Write = 'W',
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants